#include <iostream>

using namespace std;

void test()
{
    //singal variable
    int *p1 = new int();//default value
    int *p2 = new int(6);

    //new array
    int *p3 = new int[10]();
    int *p4 = new int[5]{1,2,3,4};//the last value will be init to 0

    for(int i = 0; i < 5; ++i)
    {
        cout << p4[i] << endl;
    }

    //set p1 to nullptr for safety
    delete p1;
    p1 = nullptr;

    delete p2;
    p2 = nullptr;

    delete []p3;
    p3 = nullptr;

    delete []p4;
    p4 = nullptr;

    //malloc -> free
    //new -> delete
    //new[] -> delete[]
}


int main()
{
    test();
    return 0;
}
